//
//  ViewController.m
//  NeicunTest
//
//  Created by tanqilong on 16/5/24.
//  Copyright © 2016年 tanqilong. All rights reserved.
//

#import "ViewController.h"
#import "TestView.h"

@interface ViewController ()
@property (nonatomic,strong) TestView * testView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _testView = [[TestView alloc]initWithFrame:CGRectMake(0, 100, 300, 300)];
    _testView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_testView];
    
    UIButton * button= [[UIButton alloc]initWithFrame:CGRectMake(0, 300, 50, 50)];
    [button setTitle:@"button" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor blueColor];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

-(void)buttonClicked {
//    [_testView timerIvalidate];
    [_testView removeFromSuperview];
    _testView = nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
